﻿using System;
using ScoutOffice.BLL;

public class PScoutDetails
{
    private IScoutDetails _view;

	public PScoutDetails(IScoutDetails view)
	{
        _view = view;
        RegisterEvents();
	}

    private void RegisterEvents()
    {
        _view.InitialLoad += new EventHandler(_view_InitialLoad);
        _view.SaveScout += new EventHandler(_view_SaveScout);
    }

    void _view_InitialLoad(object sender, EventArgs e)
    {
        if (_view.ScoutId.HasValue)
        {
            // TODO: fetch scout from database
            Scout s = new Scout("Joe", "Scout");
            _view.FirstName = s.FirstName;
            _view.LastName = s.LastName;
        }
    }

    void _view_SaveScout(object sender, EventArgs e)
    {
        if (_view.ScoutId.HasValue)
        {
            // TODO: update scout in database
        }
        else
        {
            // TODO: insert scout into database
            // TODO: redirect to this page with scoutid in qs
        }
    }
}
